I'm looking for a PowerShell script that I can run and will copy a file with today's date yyyymmdd.txt to a remote location renaming it to XXXXXX.log and over writing the existing *.log.
Sounds simple, but as a newbe to PS, I could use some help.
Technology Tips and News
I'm looking for a PowerShell script that I can run and will copy a file with today's date yyyymmdd.txt to a remote location renaming it to XXXXXX.log and over writing the existing *.log.
Sounds simple, but as a newbe to PS, I could use some help.
Check out: Get-Help Copy-Item -Full
That cmdlet can copy a file from one place to another, rename it, and also overwrite a pre-existing file (-Force).
Also check out Get-Help about_Variables for info on how variables work in PowerShell. You can use Get-Date -Format yyyymmdd to get the values you'll need for your source file name, then save it to a variable to use with Copy-Item.
I don't know what XXXXXX.log represents, but that might just need to be another variable.
Does that help?
Todays date is:
[datetime]::Today.ToString('yyyyMMdd')
Help Copy-Item -full